package com.senyint.hip.fhir.interceptor;

import ca.uhn.fhir.rest.client.api.IClientInterceptor;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.api.IHttpResponse;

import java.io.IOException;

/**
 * *******description*******
 * <p>
 * *************************
 *
 * @author ChenPan
 * @date 2018/10/30 11:07
 */
public class CaptureInterceptor implements IClientInterceptor {

    private IHttpRequest myLastRequest;
    private IHttpResponse myLastResponse;

    public IHttpRequest getLastRequest() {
        return myLastRequest;
    }

    public IHttpResponse getLastResponse() {
        return myLastResponse;
    }

    @Override
    public void interceptRequest(IHttpRequest theRequest) {
        assert myLastRequest == null;

        myLastRequest = theRequest;
    }

    @Override
    public void interceptResponse(IHttpResponse theResponse) throws IOException {
        assert myLastResponse == null;
        myLastResponse = theResponse;
    }

}
